package yun.web.activerecord.ext;

import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.ObjectSerializer;
import yun.web.activerecord.CPI;
import yun.web.activerecord.Model;

import java.io.IOException;
import java.lang.reflect.Type;
import java.util.Map;

public class ModelSerializer implements ObjectSerializer {
    public static ModelSerializer me = new ModelSerializer();

    @Override
    public void write(JSONSerializer jsonSerializer, Object o, Object o1, Type type, int i) throws IOException {
        if (o != null) {
            Map map = CPI.getAttrs((Model) o);
            jsonSerializer.write(map);
        }
    }
}
